package com.hanamaki.homework;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
//        System.out.println("正整数的个数为：" + count());

//        System.out.println(sushu());
//        printsushu();
//        n();
//        ysfj();

//        diffDays1();
//        re();

        printNum();
    }

    //    从键盘循环输入正整数，当输入-1时结束，统计输入的正整数的个数
    public static int count() {
        System.out.println("请输入数字");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int count = 0;
        while (num != -1) {
            if (num > 0) {
                count++;
            }
            System.out.println("请继续输入数字");
            num = scanner.nextInt();
        }
        return count;
    }


    //    从键盘输入一个整数，判断该数是否素数。素数是只能被1 和本身整除的数。可用穷举法来判断一个数是否是素数。 如果是就返回 true 如果不是就返回false
    // 算法 》 穷举法： 暴力破解法  for循环 1 3 5 7 11 13 15
    public static boolean sushu() {
        System.out.println("请输入整数");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int i;
        boolean flag = false;
        if (num == 0 || num == 1) {
            flag = false;
        }
        for (int j = 2; j <= Math.sqrt(num); j++) {
            if (num % j == 0) {
                flag = false;
            } else {
                flag = true;
            }
        }
        return flag;
    }

    //    输出100以内的所有素数
    // 素数：0 1
    public static void printsushu() {
        boolean flag = false;
        for (int i = 2; i <= 100; i++) {
            // 假设 2----100 所有的数都是素数
            flag = true;
            for (int j = 2; j < i; j++) {
                if (i % j == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                System.out.print(i + "\t");
            }
        }
        System.out.println();
    }

    public static void n() {
        for (int i = 1; i<=9; i++) {
            for (int k = 1; k < i; k++) {
                System.out.print(" ");
            }
            for (int j = 9; j >= i; j--) {
                System.out.print("*");
            }
            System.out.println();
        }
    }


    /**
     *  第 5 题
     */
    public static void ysfj() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个正整数:");
        // 90
        int num = scanner.nextInt();
        // 定义一个最小的约数  2
        int k = 2;
        System.out.print(num + "=");
        while (k <= num) {
            if (num == k) {
                System.out.println(num);
                break;
            } else if (num % k == 0) {
                System.out.print(k + "*");
                num /= k;
            } else {
                k++;
            }
        }
    }

    public static void diffDay() {
        Scanner scanner = new Scanner(System.in);
        int y, m, d;
        System.out.println("请输入年份:");
        y = scanner.nextInt();
        System.out.println("请输入月份:");
        m = scanner.nextInt();
        System.out.println("请输入日期:");
        d = scanner.nextInt();
        // 初始化变量
        int days = 0;
        for (int i = 1; i < m; i++) {
            switch (i) {
                case 2:
                    days += 28;
                    if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) {
                        days++;
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    days += 30;
                    break;
                default:
                    days += 31;
            }
        }
        days += d;
        System.out.println(y + "年" + m + "月" + d + "日是该年的第" + days + "天");

    }

    public static void diffDays1() {

        Scanner scanner = new Scanner(System.in);
        int y, m, d;
        System.out.println("请输入年份:");
        y = scanner.nextInt();
        System.out.println("请输入月份:");
        m = scanner.nextInt();
        System.out.println("请输入日期:");
        d = scanner.nextInt();

        Calendar diy = Calendar.getInstance();
        diy.set(y, 0, 1);
        long time1 = diy.getTimeInMillis();

        Calendar instance = Calendar.getInstance();
        instance.set(y, m-1, d);
        long time2 = instance.getTimeInMillis();

        long result = (time2 - time1) / 1000 / 60 / 60 / 24;

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(simpleDateFormat.format(diy.getTime()) + "距离" + simpleDateFormat.format(instance.getTime()) + "已经过去了" + result + "天");
    }


    public static void re() {
        System.out.println("请输入需要反转的数字");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        StringBuffer buffer = new StringBuffer();
        while (num != 0) {
            int r_right = num % 10;
            buffer.append(r_right);
            num /= 10;
        }

        String string = buffer.toString();
        int i = Integer.parseInt(string);
        System.out.println(i);
    }

    public static void printNum() {
        System.out.println("请输入需要打印的数字");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        for (int i = 1; i <= num; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print(num);
            }
            System.out.println();
        }

    }







}
